import locale
import stream
import layer
import adapter


def file(filename, mode = "r", bufsize = None):
    f = stream.FileStream(filename, mode)
    f = layer.BufferingLayer(f, bufsize)
    return f

def textfile(filename, mode = "r", encoding = "utf8"):
    f = stream.FileStream(filename, mode)
    f = layer.LineBufferingLayer(f)
    f = adapter.TextAdapter(f, encoding)
    return f


